//k1 edit 21.12.09

private ["_center","_rotation","_obj"];

_center = [_this, 0] call bis_fnc_param;
_rotation = random 360;

if (isNil "A3E_MortarMarkerNumber") then {
	A3E_MortarMarkerNumber = 0;
} else {
	A3E_MortarMarkerNumber = A3E_MortarMarkerNumber + 1;
};
_number = A3E_MortarMarkerNumber;

_fnc_createObject = {
    params["_className","_centerPos","_relativePos","_rotateDir","_relativeDir"];
    private["_object", "_realPos", "_realDir"];

    _fnc_rotatePos = {
        private ["_centerPos", "_pos", "_dir"];
        private ["_px", "_py", "_mpx", "_mpy", "_ma", "_rpx", "_rpy"];
        _centerPos = _this select 0;
        _pos = _this select 1;
        _dir = _this select 2;
        _px = _pos select 0;
        _py = _pos select 1;
        _mpx = _centerPos select 0;
        _mpy = _centerPos select 1;
        _ma = _dir;
        _rpx = ( (_px - _mpx) * cos(_ma) ) + ( (_py - _mpy) * sin(_ma) ) + _mpx;
        _rpy = (-(_px - _mpx) * sin(_ma) ) + ( (_py - _mpy) * cos(_ma) ) + _mpy;
        [_rpx, _rpy, (_pos select 2)];
    };

    _realPos = ([_centerPos, [(_centerPos select 0) + (_relativePos select 0), (_centerPos select 1) + (_relativePos select 1),(_relativePos select 2)], _rotateDir] call _fnc_rotatePos);
    _object = createVehicle [_className, _realPos, [], 0, "CAN_COLLIDE"];
    _object setdir (_relativeDir + _rotateDir);
    _object setPosATL _realPos;
    _object
};

_obj = objNull;
_obj = ["Land_HBarrier_5_F",_center,[-11.8982,-13.8306,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[4.97681,-13.8306,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-6.27319,-13.8306,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[10.6018,-13.8306,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[12.4768,12.2944,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-0.773193,15.9194,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-14.0232,-10.2056,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-12.0232,15.9194,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-14.0232,-4.58057,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[4.85181,15.9194,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-14.0232,1.04443,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-14.0232,6.66943,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[12.4768,1.04443,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[12.4768,-10.2056,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-14.0232,12.2944,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[10.4768,15.9194,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[12.4768,6.66943,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-6.39819,15.9194,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[12.4768,-4.58057,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[-18.5232,9.66943,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[-18.5232,-0.330566,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[-18.5232,-10.3306,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[1.85181,19.1694,0],_rotation,180] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[16.3518,-0.71,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[16.3518,9.3,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[16.3518,-10.71,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[11.8518,19.17,0],_rotation,180] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[-8.14819,19.17,0],_rotation,180] call _fnc_createObject;
_obj = ["Land_New_WiredFence_5m_F",_center,[-15.6482,19.17,0],_rotation,180] call _fnc_createObject;
_obj = ["Land_New_WiredFence_5m_F",_center,[-18.5232,17.17,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_5m_F",_center,[16.3518,16.8,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_BagFence_Round_F",_center,[-8.88892,-5.19,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_BagFence_Round_F",_center,[-11.6389,-2.565,0],_rotation,90] call _fnc_createObject;
_obj = ["Land_BagFence_Round_F",_center,[-8.88892,0.06,0],_rotation,180] call _fnc_createObject;
_obj = ["Land_BagFence_Round_F",_center,[-6.26392,-2.565,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_3_F",_center,[-4.27,-16.33,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_3_F",_center,[2.852,-16.33,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_Cargo_House_V1_F",_center,[-8.15,4.8,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_Cargo_House_V1_F",_center,[-8.1482,11.044,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_BarGate_F",_center,[-0.9,-18.83,0],_rotation,180] call _fnc_createObject;
_obj = ["Land_BagBunker_Small_F",_center,[-9.52,-18.8,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_Cargo_Patrol_V1_F",_center,[8.352,-9.71,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_Cargo_HQ_V1_F",_center,[4.977,6.3,0],_rotation,270] call _fnc_createObject;

_obj = ["Box_East_Ammo_F",_center,[-0.53,11.03,1],_rotation,0] call _fnc_createObject;
_obj allowDamage false;
_obj = ["Box_East_WpsLaunch_F",_center,[-0.51,9.5,1],_rotation,0] call _fnc_createObject;
_obj allowDamage false;
_obj = ["Box_East_Wps_F",_center,[-0.45,12.6,1],_rotation,0] call _fnc_createObject;
_obj allowDamage false;
_obj = ["Box_East_WpsSpecial_F",_center,[-11.3,11.15,1],_rotation,0] call _fnc_createObject;
_obj allowDamage false;
_obj = ["Box_East_WpsSpecial_F",_center,[-11.3,5.2,1],_rotation,0] call _fnc_createObject;
_obj allowDamage false;
_obj = ["O_CargoNet_01_ammo_F",_center,[-9.6,-9.61,0],_rotation,270] call _fnc_createObject;
_obj allowDamage false;

//Statics
_MGGMH = a3e_arr_Escape_SWC_MG_H + a3e_arr_Escape_SWC_GM_H;
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-9.64819,-19.2056,0],_rotation,180] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[9.6731,-10.8525,4.33],_rotation,135] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-0.157959,12.1812,3.1],_rotation,315] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[2.22681,3.54443,3.11],_rotation,225] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[6.85132,13.3921,3.11],_rotation,0] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[9.76392,5.29443,3.11],_rotation,90] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];

_StaticWeapons = a3e_arr_Escape_SWC_MG + a3e_arr_Escape_SWC_MG_A;
_gun = selectRandom _StaticWeapons;
_obj = [_gun,_center,[9.484,-11.8,0.1],_rotation,270] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _StaticWeapons;
_obj = [_gun,_center,[-4.381,13.32,0.1],_rotation,180] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];

_gun = selectRandom a3e_arr_MortarSite; //
_obj = [_gun,_center,[-9.014,-2.81,0.04],_rotation,90] call _fnc_createObject;
[_obj,A3E_VAR_Side_Opfor] spawn A3E_fnc_AddStaticGunner;
Escape_all_assets pushback _obj;
a3e_var_artillery_units pushBack _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom a3e_arr_MortarSite; //
_obj = [_gun,_center,[4.92,6.034,3.16],_rotation,90] call _fnc_createObject;
[_obj,A3E_VAR_Side_Opfor] spawn A3E_fnc_AddStaticGunner;
Escape_all_assets pushback _obj;
a3e_var_artillery_units pushBack _obj;
_obj setVariable ["Escape_assets_control", true, true];

Escape_campType_arr pushback [_center,"迫击炮点","Jade"];
publicVariable "Escape_campType_arr";

["A3E_MortarSiteMapMarker" + str _number,_center,"o_mortar"] call A3E_fnc_createLocationMarker;

_marker = createMarkerLocal ["A3E_MortarSitePatrolMarker" + str _number, _center];
_marker setMarkerShapeLocal "ELLIPSE";
_marker setMarkerAlpha 0;
_marker setMarkerSizeLocal [50, 50];


